package com.lywz.biz.service.scenic.impl;

import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lywz.biz.common.dao.CommonDao;
import com.lywz.biz.common.entity.scenic.Attraction;
import com.lywz.biz.common.entity.scenic.Scenic;
import com.lywz.biz.common.entity.scenic.ScenicAround;
import com.lywz.biz.common.entity.scenic.ScenicHomepage;
import com.lywz.biz.common.entity.scenic.ScenicImage;
import com.lywz.biz.common.entity.scenic.ScenicVideo;
import com.lywz.biz.dao.scenic.ScenicDao;
import com.lywz.biz.logic.scenic.ScenicLogic;
import com.lywz.biz.service.scenic.ScenicService;
import com.lywz.core.util.CommonDefaultCheck;

/**
 * 景区Service实体类
 * 
 * @author Huadi Luojun
 * @date 2010-5-3
 */

@Service("scenicService")
public class ScenicServiceImpl implements ScenicService {

    @Autowired
    private ScenicDao scenicDao;

    @Autowired
    private CommonDao commonDao;
    
    @Autowired
    private ScenicLogic scenicLogic;

    @SuppressWarnings("unchecked")
    @Override
    public List<ScenicHomepage> getHomepageList() {
        List<ScenicHomepage> scenicHomepage = null;
        try {
            scenicHomepage = scenicDao.getHomepageList();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (List<ScenicHomepage>) CommonDefaultCheck.checkDefault(scenicHomepage);
    }

    @Override
    public List<ScenicHomepage> getCategoryList(Integer category) {
        List<ScenicHomepage> scenicCategory = Collections.emptyList();
        try {
            scenicCategory = scenicDao.getCategoryList(category);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return scenicCategory;
    }

    @Override
    public Scenic getOneScenic(Integer scenicId) {
        Scenic oneScenic = new Scenic();
        try {
            oneScenic = commonDao.queryById(Scenic.class, scenicId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return oneScenic;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ScenicAround> getAroundScenicList(Integer scenic) {
        List<ScenicAround> scenicAround = null;
        try {
            scenicAround = scenicDao.getScenicAround(scenic);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (List<ScenicAround>) CommonDefaultCheck.checkDefault(scenicAround);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Attraction> getAttractionList(Integer scenicId) {
        List<Attraction> attractionList = null;
        try {
            attractionList = scenicDao.getAttractionList(scenicId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (List<Attraction>) CommonDefaultCheck.checkDefault(attractionList);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ScenicImage> getScenicImage(Integer scenicId) {

        List<ScenicImage> scenicImage = null;

        try {
            scenicImage = scenicDao.getScenicImage(scenicId);
        } catch (Exception e) {

            e.printStackTrace();
        }
        return (List<ScenicImage>) CommonDefaultCheck.checkDefault(scenicImage);
    }

    @SuppressWarnings("unchecked")
    public List<ScenicVideo> getScenicVideo(Integer scenicId) {
        List<ScenicVideo> scenicVideo = null;
        try {
            scenicVideo = scenicDao.getScenicVideo(scenicId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (List<ScenicVideo>) CommonDefaultCheck.checkDefault(scenicVideo);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Scenic> getCategoryScenicList(Integer category, Integer city, Integer level) {
        List<Scenic> categoryScenicList = null;
        try {
            categoryScenicList = scenicDao.getCategoryScenicList(category, city, level);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (List<Scenic>) CommonDefaultCheck.checkDefault(categoryScenicList);
    }

    //后台管理Service===========================================================================
    @SuppressWarnings("unchecked")
    @Override
    public void deleteOneScenic(Integer scenicId) {
        scenicLogic.deleteScenic(scenicId);
    }
}
